/*
 * @Author: duchengdong
 * @Date: 2021-12-28 15:16:05
 * @LastEditors: duchengdong
 * @LastEditTime: 2021-12-31 14:00:31
 * @Description:
 */
import {authPhoneApi} from '@/service/authApi'
const authPhone = {
	data() {
		return {
			phone_loading: false,
		}
	},
	methods: {
		async authPhoneNumber(e) {
			console.log('获取手机号', e)
			if (this.phone_loading) return
			let phone_userInfo = this.$utils.getStorage('userInfo')
			const {openId, unionId} = phone_userInfo
			this.phone_loading = true
			if (e.detail.encryptedData) {
				let params = {
					encryptedData: e.detail.encryptedData,
					iv: e.detail.iv,
					openId: openId,
					unionId: unionId,
				}
				let res = await authPhoneApi(params)
				setTimeout(() => {
					this.phone_loading = false
				}, 1500)
				if (res.code == 100) {
					return res.data.phoneNumber
				} else {
					return false
				}
			}
			return false
		},
	},
}
export default authPhone
